﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Basics
{
    abstract class DrawableObject : WorldObject
    {
        public enum FacingDirection
        {
            NORTH = 1,
            NORTH_EAST = 3,
            EAST = 2,
            SOUTH_EAST = 6,
            SOUTH = 4,
            SOUTH_WEST = 12,
            WEST = 8,
            NORTH_WEST = 9,
        }

        public float DrawPriority { get; set; }
        public Texture2D Texture { get; set; }
        public double Rotation { get; set; }
        protected Vector2 rotationOrigin;
        public float Scale { get; set; }

        public FacingDirection facingDirection { get; set; }

        public DrawableObject()
        {
            this.Rotation = 0;
            this.Scale = 1;
            this.DrawPriority = 0;
        }

        public DrawableObject(Texture2D texture, float drawPriority)
        {
            this.Texture = texture;
            this.Rotation = 0;
            this.rotationOrigin = new Vector2(this.Texture.Width / 2, this.Texture.Height / 2);
            this.Scale = 1;
        }

        virtual public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(this.Texture, this.Position, new Rectangle(0, 0, this.Texture.Width, this.Texture.Height), Color.White, (float)this.Rotation, this.rotationOrigin, this.Scale, SpriteEffects.None, this.DrawPriority);
            spriteBatch.End();
        }

        virtual public void Rotate(double angle)
        {
            this.Rotation = angle;
        }
    }
}
